Skip to main content

Push Notifications

The SignalWire platform can be configured to send push notifications to a subscriber that is being called. When the subscriber's device receives a push notification, it will make the device ring and forward the notification to your application. Your application should set up an audio/video link if the user accepts the call using the handlePushNotification method. The push notification is only sent if there is no active WebSocket connection to the subscriber at that moment.

Setup

To be able to receive push notifications to your applications, device-specific configurations are required.

For iOS, generate a VoIP services certificate from the Apple Developer website.

For Android, acquire the FCM API key. It can be found at the Firebase project settings under Cloud Messaging tab. To get the API key, you might have to explicitly enable "Cloud Messaging API (Legacy)".

info

There is no UI to upload the certificates for push to SignalWire yet. Please get in touch with SignalWire support who'll promptly configure your account with the certificates you want.

Handling Push Notifications

The push notification is a compressed and encrypted JSON payload which contains the caller details and the invitation that needs to be passed into the SDK to join the call.

To receive push notifications, after the app is configured with the certificates or tokens as per device requirements, the device needs to be registered using the client.registerDevice method. The registerDevice method expects a token, which the OS provides only if the user explicitly allows the app to receive push notifications.

The registerDevice method, if successful, returns a push notification decryption key, which must be saved and used to decrypt push notification messages as they are received.

Payload

Each platform has its own schema but the core message has the following attributes:

NameTypeDescription
encryption_typestringType of encryption used ('aes_256_gcm' or 'none')
notification_uuidstringUUID of the push notification
with_videostringIndicates whether the call includes video ("true" | "false")
incoming_caller_namestringName of the incoming caller
incoming_caller_idstringID of the incoming caller
invitestringInvitation (base 64 encoded, compressed, and possibly encrypted)
titlestringTitle of the call
typestringType of notification ('call_invite')
ivstringThe initialization vector of the encryption (base 64)
tagstringThe tag info for the encryption (base 64)
versionstringThe version of the push notification received

iOS

In iOS platform devices will wrap the payload in the following structure.

Payload
{
"aps": {
"alert": {
...payload
}
}
}

On iOS, a special VoIP push notification will be sent which automatically invokes the system's incoming call UI.

Android and Web Notifications

Android and web platforms will wrap the payload in the following structure.

Payload
{
"notification": {
"body": "JSON stringified payload"
},
"data": {}
}

Handling the notification payload

Once the payload has been received, the invite needs to be decoded from Base64, decompressed, and decrypted using the key received during device registration. Sample implementations in React Native and for iOS are available.

Alternatively, a sample React Native project is available in the community repo.